﻿using Map;
using Map_Creator.MapInfo;

namespace Map_Creator.RedoUndo.Actions
{
    class AddLayerAction:IAction
    {
        private int mapID;
        private Layer layer;
        private int layerID = 0;

        public AddLayerAction(MapInfo.Map map)
        {
            mapID = map.ID;
        }

        public void Do()
        {
            var map = ((MapInfo.Map)BaseObject.Objects[mapID]);
            map.AddTopLayer(layerID);
            layer = map[map.Levels - 1];
            layerID = layer.ID;
        }

        public void Undo()
        {
            layer.Delete();
        }

        public string GetDescription()
        {
            return "Adds a Top Layer";
        }

        public string GetName()
        {
            return "Add Layer";
        }
    }
}
